home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 June: Reference Library / Dev.CD Jun 94.toast / Periodicals / develop / develop Issue 15 / develop 15 code / Floating Windows / Sample / Source / trapAvail.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-11-06  |  783 b   |  45 lines  |  [TEXT/MPS ]

  1. /*
  2.     TrapAvail — Determine the existence of a trap
  3. */
  4.  
  5. #include <Types.h>
  6. #include <Traps.h>
  7. #include <OSUtils.h>
  8.  
  9. short        NumToolboxTraps(void);
  10. TrapType    GetTrapType(short theTrap);
  11.     
  12. Boolean    TrapAvailable(short theTrap)
  13. {
  14.     TrapType    tType;
  15.     Boolean        isAvail;
  16.     
  17.     tType = GetTrapType(theTrap);
  18.     if (tType == ToolTrap)
  19.         {
  20.             theTrap &= 0x07FF;
  21.             if (theTrap >= NumToolboxTraps())
  22.                 theTrap = _Unimplemented;
  23.         }
  24.     
  25.     isAvail = NGetTrapAddress(theTrap, tType) != NGetTrapAddress(_Unimplemented, ToolTrap);
  26.     return isAvail;
  27. }
  28.  
  29. short    NumToolboxTraps()
  30. {
  31.     if (NGetTrapAddress(_InitGraf, ToolTrap) == NGetTrapAddress(0xAA6E,ToolTrap))
  32.         return 0x0200;
  33.     else
  34.         return 0x0400;
  35. }
  36.  
  37. TrapType    GetTrapType(short theTrap)
  38. {
  39.     if ((theTrap & 0x0800) > 0)
  40.         return ToolTrap;
  41.     else
  42.         return OSTrap;
  43. }
  44.  
  45.